ICS_APPNAME, PRGMNAME, // name of this application
ICS_APPNAMEVERSION, NUMVERSION, // version of this application
ICS_APPICSVERSION, 2, // version of ICS library this application was made for/with
ICS_PREFSFILE, prefsfile,
TAG_DONE)))
{
ErrMes(win2, MSG_ICSERR_NOCONTEXT); // Error: Can't create device context using ics.library\n Maybe not enough memory?
return(0);
}
}
if(!nosetup) // Does calling function want a setup?
{
if(idctrans) // delete any old transformation before new setup.
{
DeleteIDCTransform(idctrans);
idctrans = NULL;
}
if(SetupIDCColorMatching(idc, dscreen, TAG_DONE)<=1) // display ICS preference window. Note: ICSConvert currently does not offer any GUI. So I abort if the user selects cancel... - returns 0=err, 1=user cancel
{
temp = ICSFault(idc, MyGetString(MSG_ICSERR_MSGHEADER)); // Error while running ICSConvert.
if(!temp) temp = MyGetString(MSG_ICSERR_NOPREFS); // "Error: Can't open ICS preferences.";
if(ICSErr(idc)>ICS_ERRMSGLIMIT) Mes(temp, win2);
return(0);
}
}
if(idctrans) ICSStatusWin(idctrans, ICS_StatusText, MyGetString(MSG_ICSSTATUS_OPENSRCFILE), TAG_DONE); // change title and text of status window created by ICS library during CreateIDCTransform(): "Opening image file..."
sprintf(tempstr, PRGMNAME": %s", FilePart(inputfile)); // Generate window title of ICS status window
if(!idctrans) // Is there a transformation function available from a previous call - if not, make one now
{
if(!(idctrans = CreateIDCTransform(idc,
ICS_TransferDevices, ICS_INPUT_DEVICE, // We want to convert from input to display device (not printer device)
((nostatus) ? TAG_DONE: ICS_StatusOpen), dscreen, // Screen to use for status window or NULL for default public screen
ICS_StatusTitle, tempstr, // Overwrite status window title with our own: "ICS Image Conversion"
//ICS_StatusActivate, TRUE, // Activate status window
ICS_StatusKeep, TRUE, // keep status window open as we use the ics status window during conversion of image data later
// ICS_StatusDisableAbort, TRUE, // use this to disable Abort/Stop button
TAG_DONE))) // create input (scanner) to device (display/monitor) color corretion and show status window while processing.. leave status window open for user below...
{
temp = ICSFault(idc, MyGetString(MSG_ICSERR_MSGHEADER)); // Error while running ICSConvert.
if(!temp) temp = MyGetString(MSG_ICSERR_CREATETRANSFORM); // Error: Can't create color transformation using ics.library.
if(ICSErr(idc)>ICS_ERRMSGLIMIT) Mes(temp, win2);
return(0);
}
} else
{
ICSStatusWin(idctrans, ICS_StatusTitle, tempstr, ICS_StatusText, MyGetString(MSG_ICSSTATUS_OPENSRCFILE), TAG_DONE); // change status window for new file
temp = ICSFault(idc, MyGetString(MSG_ICSERR_CONVERT)); // Error while converting color using ICS.
if(!temp) temp = MyGetString(MSG_ICSERR_CONVERT);
if(ICSErr(idc)>ICS_ERRMSGLIMIT) Mes(temp, win2);
ret = 0;
break;
}
r = temp;
for(x=0, gray=linebuffer; (ret) && (x<ilbm->wssize); x++, gray++) // loop for number of pixels in line
{
*r++ = gray->gray >> 8;
}
} else
{
r = temp;
g = r + ilbm->wssize;
b = g + ilbm->wssize;
for(x=0, rgb=linebuffer; (ret) && (x<ilbm->wssize); x++, rgb++) // loop for number of pixels in line
{
rgb->red = (r[x]<<8) | r[x]; // convert 8 bit to 16 bit unsigned RGB color
rgb->green = (g[x]<<8) | g[x];
rgb->blue = (b[x]<<8) | b[x];
}
savemode = ((ilbm->savemode) ? COLOR_UGRAY : COLOR_URGB); // note: linebuffer is used as input and output but input maybe URGB while output is UGRAY. This only works because UGRAY is smaller than URGB.
temp = ICSFault(idc, MyGetString(MSG_ICSERR_CONVERT)); // Error while converting color using ICS.
if(!temp) temp = MyGetString(MSG_ICSERR_CONVERT);
if(ICSErr(idc)>ICS_ERRMSGLIMIT) Mes(temp, win2);
ret = 0;
break;
}
if(ilbm->savemode) // is the output gray or color?
{
r = temp;
for(x=0, gray=linebuffer; (ret) && (x<ilbm->wssize); x++, gray++) // loop for number of pixels in line
{
*r++ = gray->gray >> 8;
}
} else
{
r = temp;
g = r + ilbm->wssize;
b = g + ilbm->wssize;
for(x=0, rgb=linebuffer; (ret) && (x<ilbm->wssize); x++, rgb++) // loop for number of pixels in line
{
*r++ = rgb->red >> 8; // Convert 16 to 8 Bit - Correct would be to devide by 65535/255=257 and not 256... but we ignore the invisible fault introduced...